package com.service.impl;

import com.bean.OrderDetail;
import com.mapper.OrderDetailMapper;
import com.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDetailServiceImpl implements OrderDetailService {
    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Override
    public OrderDetail getOrderDetailById(Integer detailId) {
        return orderDetailMapper.getOrderDetailById(detailId);
    }

    @Override
    public List<OrderDetail> getOrderDetailsByOrderId(Integer orderId) {
        return orderDetailMapper.getOrderDetailsByOrderId(orderId);
    }

    @Override
    public boolean insertOrderDetail(OrderDetail orderDetail) {
        int result = orderDetailMapper.insertOrderDetail(orderDetail);
        return result > 0;
    }

    @Override
    public boolean updateOrderDetail(OrderDetail orderDetail) {
        int result = orderDetailMapper.updateOrderDetail(orderDetail);
        return result > 0;
    }

    @Override
    public boolean deleteOrderDetailById(Integer detailId) {
        int result = orderDetailMapper.deleteOrderDetailById(detailId);
        return result > 0;
    }
}